//
//  LKAddProtocalMessageViewController.m
//  YLHelper
//
//  Created by she1323 on 2018/5/3.
//  Copyright © 2018年 she1323. All rights reserved.
//

#import "LKAddProtocalMessageViewController.h"
#import "LKAddProtocalMessageCell.h"
#import "LKDayInforPersonEditSpecialCell.h"
#import "LKOrderEditBottomView.h"
#import "LKChooseBankCardViewController.h"
#import "GFDatePicker.h"
@interface LKAddProtocalMessageViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)LKBaseTableview *tableview;
@property(nonatomic,strong)LKOrderEditBottomView *bottomView;
@property(nonatomic,strong)NSArray *titlesArray;
@end

@implementation LKAddProtocalMessageViewController

-(LKBaseTableview *)tableview{
    if (!_tableview) {
        WS(weakSelf)
        _bottomView = [[[NSBundle mainBundle] loadNibNamed:@"LKOrderEditBottomView" owner:self options:nil] lastObject];
        [self.view addSubview:_bottomView];
        [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self.view);
            make.height.mas_equalTo(69);
        }];
        [[_bottomView.forwardBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            [weakSelf.navigationController popViewControllerAnimated:YES];
        }];
        [[_bottomView.nextBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
            
            if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
                if ([NSString isBlankString:self.addOrderModel.ContractCode]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入合同编号"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.ContinueInvestmentAmount]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入追加金额"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.AdditionalInterestRate]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入附加利率"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.CalulationDate]) {
                    [SVProgressHUD showInfoWithStatus:@"请选择起息日期"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.PaymentCategory]) {
                    [SVProgressHUD showInfoWithStatus:@"请选择支付方式"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.TransactionReferenceNumber]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入交易参考号"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.PosCode]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入POS机终端号"];
                    return ;
                }
                NSInteger investMoney = [self.addOrderModel.PreviousOrderInvestmentAmount integerValue] + [self.addOrderModel.ContinueInvestmentAmount integerValue];
                NSString *investMoneyStr = [NSString stringWithFormat:@"%ld",investMoney];
                self.addOrderModel.InvestmentAmount = investMoneyStr;
                
            }else{
                if ([NSString isBlankString:self.addOrderModel.ContractCode]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入合同编号"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.InvestmentAmount]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入投资金额"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.AdditionalInterestRate]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入附加利率"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.CalulationDate]) {
                    [SVProgressHUD showInfoWithStatus:@"请选择起息日期"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.PaymentCategory]) {
                    [SVProgressHUD showInfoWithStatus:@"请选择支付方式"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.TransactionReferenceNumber]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入交易参考号"];
                    return ;
                }
                if ([NSString isBlankString:self.addOrderModel.PosCode]) {
                    [SVProgressHUD showInfoWithStatus:@"请输入POS机终端号"];
                    return ;
                }
            }
            NSDate *date = [NSString getPriousorLaterDateFromDate:[NSString getDateAccordingTimeStr:self.addOrderModel.CalulationDate] withMonth:[self.addOrderModel.ProductTerm integerValue]];
            NSTimeInterval interTime = 24 *60 *60;
            NSDate *lastDate = [date dateByAddingTimeInterval:-interTime];
            self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:lastDate];
//            self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:date];
            
            LKChooseBankCardViewController *vc = [[LKChooseBankCardViewController alloc] init];
            vc.customermodel = weakSelf.customermodel;
            vc.addOrderModel = weakSelf.addOrderModel;
            [weakSelf.navigationController pushViewController:vc animated:YES];
        }];
        _tableview = [LKBaseTableview setTableviewWithFrame:CGRectMake(0, NAVIGATION_BAR_HEIGHT + 10, WIDTH , HEIGHT - NAVIGATION_BAR_HEIGHT - 10 - 70) style:UITableViewStylePlain registercellClasss:@[@"LKAddProtocalMessageCell",@"LKDayInforPersonEditSpecialCell"]];
        [self.view addSubview:_tableview];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        _tableview.backgroundColor = [UIColor whiteColor];
        _tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    return _tableview;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.addOrderModel.PaymentCategory = @"1";
    if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
        if (self.isUpdateOrder) {
            
        }else{
            self.addOrderModel.ContractCode = nil;
        }

//        self.addOrderModel.CalulationDate = self.addOrderModel.enExpireDateTest;
    }else{
        
    }
    if (self.isUpdateOrder) {
        self.tableview.frame = CGRectMake(0, NAVIGATION_BAR_HEIGHT + 10, WIDTH , HEIGHT - NAVIGATION_BAR_HEIGHT - 10);
        [self.bottomView removeFromSuperview];
        self.tableview.estimatedRowHeight = 200;
    }else{
       self.tableview.estimatedRowHeight = 200;
    }
    
    // Do any additional setup after loading the view.
}
//-(void)back{
//    if (self.isUpdateOrder) {
//        if (self.sendAddOrderBlock) {
//            self.sendAddOrderBlock(self.addOrderModel);
//            [self.navigationController popViewControllerAnimated:YES];
//        }
//
//    }else{
//        [super back];
//    }
//}
-(void)setNavgationBackBtn{
    [super setNavgationBackBtn];
    self.navigationItem.title = @"添加协议信息";
    if (self.isUpdateOrder) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        btn.titleLabel.font = [UIFont systemFontOfSize:16];
        [btn setTitle:@"保存" forState:UIControlStateNormal];
        [btn setTitleColor:blueDefault forState:UIControlStateNormal];
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
        [btn addTarget:self action:@selector(orderUpdateBlock) forControlEvents:UIControlEventTouchUpInside];
    }
}

/**
 订单编辑或者变更的时候的反向传值
 */
-(void)orderUpdateBlock{
    
    if ([self.addOrderModel.CalulationDate containsString:@"T"]) {
            self.addOrderModel.CalulationDate = [[self.addOrderModel.CalulationDate componentsSeparatedByString:@"T"] firstObject];
    }else{
        
    }
            if (self.sendAddOrderBlock) {
                
                if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
                    
                    NSDate *date = [NSString getPriousorLaterDateFromDate:[NSString getDateAccordingTimeStr:self.addOrderModel.CalulationDate] withMonth:[self.addOrderModel.ProductTerm integerValue]];
                    NSTimeInterval interTime = 24 *60 *60;
                    NSDate *lastDate = [date dateByAddingTimeInterval:-interTime];
                    self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:lastDate];
                    //                    self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:date];
                    self.addOrderModel.EndEntityDateTest = [NSString getTimeStrAccoringDate:lastDate];
                }else{
                    NSDate *date = [NSString getPriousorLaterDateFromDate:[NSString getDateAccordingTimeStr:self.addOrderModel.CalulationDate] withMonth:[self.addOrderModel.ProductTerm integerValue]];
                    NSTimeInterval interTime = 24 *60 *60;
                    NSDate *lastDate = [date dateByAddingTimeInterval:-interTime];
                    self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:lastDate];
//                    self.addOrderModel.EndEntityDate = [NSString getTimeStrAccoringDate:date];
                    self.addOrderModel.EndEntityDateTest = [NSString getTimeStrAccoringDate:lastDate];
                }
                self.sendAddOrderBlock(self.addOrderModel);
                [self.navigationController popViewControllerAnimated:YES];
            }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titlesArray.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WS(weakSelf)
    LKAddProtocalMessageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKAddProtocalMessageCell"];
    cell.titleLabel.text = self.titlesArray[indexPath.row];
    cell.arrowBtn.hidden = YES;
    cell.lineView.hidden = YES;
    cell.pictureImageView.hidden = YES;
    cell.contentTF.tag = 1000 + indexPath.row;
    cell.contentTF.enabled = YES;
    cell.contentTF.placeholder = @"输入时请注意字母大写";
    [cell.contentTF addTarget:self action:@selector(changeChooseValue:) forControlEvents:UIControlEventEditingChanged];
    if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
        switch (indexPath.row) {
            case 0:
            {
//                cell.contentTF.placeholder = @"输入时请注意字母大写";
                cell.contentTF.text = self.addOrderModel.ContractCode;
            }
                break;
//            case 1:
//            {
//                cell.contentTF.text = self.addOrderModel.InvestmentAmount;
////                cell.contentTF.enabled = NO;
//            }
//                break;
            case 1:
            {
                cell.contentTF.placeholder = @"请注意单位为元";
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                cell.contentTF.text = self.addOrderModel.ContinueInvestmentAmount;
                
            }
                break;
            case 2:
            {
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                cell.contentTF.text = self.addOrderModel.AdditionalInterestRate;
            }
                break;
            case 3:
            {
                
            }
                break;
            case 4:
            {
                
            }
                break;
            case 5:
            {
                cell.contentTF.placeholder = @"两个以上的交易参考号”/“用隔开";
                cell.contentTF.text = self.addOrderModel.TransactionReferenceNumber;
            }
                break;
            case 6:
            {
                cell.contentTF.text = self.addOrderModel.PosCode;
            }
                break;
            default:
                break;
        }
        if (indexPath.row == 3 || indexPath.row == 4) {
            cell.lineView.hidden = NO;
            cell.contentTF.placeholder = @"请选择";
            cell.contentTF.enabled = NO;
            cell.arrowBtn.hidden = NO;
            if (indexPath.row == 3) {
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                if (self.addOrderModel.EndEntityDate) {
                    self.addOrderModel.CalulationDate = self.addOrderModel.EndEntityDate;
                }else{
                    self.addOrderModel.CalulationDate = [NSString getTimeStrAccoringDate:[NSDate date]];
                }
                
                cell.contentTF.text = [[self.addOrderModel.CalulationDate componentsSeparatedByString:@"T"] firstObject];
            }
            if (indexPath.row == 4) {
                cell.contentTF.text = [self.addOrderModel.PaymentCategory integerValue] == 0 ? @"转账":@"POS终端";
            }
        }
        if (indexPath.row == self.titlesArray.count - 1) {
            LKDayInforPersonEditSpecialCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKDayInforPersonEditSpecialCell"];
            cell.bgview.layer.borderColor = COLOR_HEX(0xDCDBDC).CGColor;
            cell.bgview.layer.borderWidth = 1;
            [cell.titiLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).offset(34);
                make.top.equalTo(cell.contentView.mas_top).offset(22);
            }];
            [cell.bgview mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).offset(34); make.top.equalTo(cell.titiLabel.mas_bottom).offset(12);
                make.height.mas_equalTo(120);
            }];
            cell.titiLabel.text = self.titlesArray[indexPath.row];
            cell.textView.text = weakSelf.addOrderModel.Supplement;
            [cell.textView.rac_textSignal subscribeNext:^(NSString * _Nullable x) {
                weakSelf.addOrderModel.Supplement = x;
            }];
            return cell;
        }
    }else{
        switch (indexPath.row) {
            case 0:
            {
                cell.contentTF.text = self.addOrderModel.ContractCode;
            }
                break;
            case 1:
            {
                cell.contentTF.placeholder = @"请注意单位为元";
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                cell.contentTF.text = self.addOrderModel.InvestmentAmount;
            }
                break;
            case 2:
            {
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                cell.contentTF.text = self.addOrderModel.AdditionalInterestRate;
                
            }
                break;
            case 3:
            {
                
            }
                break;
            case 4:
            {
                
            }
                break;
            case 5:
            {
                cell.contentTF.placeholder = @"两个以上的交易参考号”/“用隔开";
                cell.contentTF.text = self.addOrderModel.TransactionReferenceNumber;
            }
                break;
            case 6:
            {
                cell.contentTF.text = self.addOrderModel.PosCode;
            }
                break;
            default:
                break;
        }
        if (indexPath.row == 3 || indexPath.row == 4) {
            cell.lineView.hidden = NO;
            cell.contentTF.placeholder = @"请选择";
            cell.contentTF.enabled = NO;
            cell.arrowBtn.hidden = NO;
            if (indexPath.row == 3) {
                if (self.isOrderBianGeng) {
                    cell.contentTF.enabled = NO;
                }
                cell.contentTF.text = [[self.addOrderModel.CalulationDate componentsSeparatedByString:@"T"] firstObject];
            }
            if (indexPath.row == 4) {
                cell.contentTF.text = [self.addOrderModel.PaymentCategory integerValue] == 0 ? @"转账":@"POS终端";
            }
        }
        if (indexPath.row == self.titlesArray.count - 1) {
            LKDayInforPersonEditSpecialCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKDayInforPersonEditSpecialCell"];
            cell.bgview.layer.borderColor = COLOR_HEX(0xDCDBDC).CGColor;
            cell.bgview.layer.borderWidth = 1;
            [cell.titiLabel mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).offset(34);
                make.top.equalTo(cell.contentView.mas_top).offset(22);
            }];
            [cell.bgview mas_updateConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(cell.contentView.mas_left).offset(34); make.top.equalTo(cell.titiLabel.mas_bottom).offset(12);
                make.height.mas_equalTo(120);
            }];
            cell.titiLabel.text = self.titlesArray[indexPath.row];
            cell.textView.text = weakSelf.addOrderModel.Supplement;
            [cell.textView.rac_textSignal subscribeNext:^(NSString * _Nullable x) {
                weakSelf.addOrderModel.Supplement = x;
            }];
            return cell;
        }
    }
//    switch (indexPath.row) {
//        case 0:
//            {
//                cell.contentTF.text = self.addOrderModel.ContractCode;
//            }
//            break;
//        case 1:
//        {
//            cell.contentTF.text = self.addOrderModel.InvestmentAmount;
//        }
//            break;
//        case 2:
//        {
//            cell.contentTF.text = self.addOrderModel.AdditionalInterestRate;
//
//        }
//            break;
//        case 3:
//        {
//
//        }
//            break;
//        case 4:
//        {
//
//        }
//            break;
//        case 5:
//        {
//            cell.contentTF.text = self.addOrderModel.TransactionReferenceNumber;
//        }
//            break;
//        case 6:
//        {
//            cell.contentTF.text = self.addOrderModel.PosCode;
//        }
//            break;
//        default:
//            break;
//    }
//    if (indexPath.row == 3 || indexPath.row == 4) {
//        cell.lineView.hidden = NO;
//        cell.contentTF.placeholder = @"请选择";
//        cell.contentTF.enabled = NO;
//        cell.arrowBtn.hidden = NO;
//        if (indexPath.row == 3) {
//            cell.contentTF.text = [[self.addOrderModel.CalulationDate componentsSeparatedByString:@"T"] firstObject];
//        }
//        if (indexPath.row == 4) {
//            cell.contentTF.text = [self.addOrderModel.PaymentCategory integerValue] == 0 ? @"转账":@"POS终端";
//        }
//    }
//    if (indexPath.row == self.titlesArray.count - 1) {
//        LKDayInforPersonEditSpecialCell *cell = [tableView dequeueReusableCellWithIdentifier:@"LKDayInforPersonEditSpecialCell"];
//        cell.bgview.layer.borderColor = COLOR_HEX(0xDCDBDC).CGColor;
//        cell.bgview.layer.borderWidth = 1;
//        [cell.titiLabel mas_updateConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(cell.contentView.mas_left).offset(34);
//            make.top.equalTo(cell.contentView.mas_top).offset(22);
//        }];
//        [cell.bgview mas_updateConstraints:^(MASConstraintMaker *make) {
//           make.left.equalTo(cell.contentView.mas_left).offset(34); make.top.equalTo(cell.titiLabel.mas_bottom).offset(12);
//            make.height.mas_equalTo(120);
//        }];
//        cell.titiLabel.text = self.titlesArray[indexPath.row];
//        cell.textView.text = weakSelf.addOrderModel.Supplement;
//        [cell.textView.rac_textSignal subscribeNext:^(NSString * _Nullable x) {
//            weakSelf.addOrderModel.Supplement = x;
//        }];
//        return cell;
//    }
    return cell;
}

/**
 文本输入编辑改变

 */
-(void)changeChooseValue:(UITextField *)tf{
    if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
        switch (tf.tag - 1000) {
            case 0:
            {
                self.addOrderModel.ContractCode = tf.text;
                
            }
                break;
//            case 1:
//            {
//                self.addOrderModel.InvestmentAmount = tf.text;
//            }
//                break;
            case 1:
            {
                self.addOrderModel.ContinueInvestmentAmount = tf.text;
            }
                break;
            case 2:
            {
                self.addOrderModel.AdditionalInterestRate = tf.text;
            }
                break;
            case 5:
            {
                self.addOrderModel.TransactionReferenceNumber = tf.text;
                
            }
                break;
            case 6:
            {
                self.addOrderModel.PosCode = tf.text;
            }
                break;
            default:
                break;
        }
    }else{
        switch (tf.tag - 1000) {
            case 0:
            {
                self.addOrderModel.ContractCode = tf.text;
                
            }
                break;
            case 1:
            {
                self.addOrderModel.InvestmentAmount = tf.text;
            }
                break;
            case 2:
            {
                self.addOrderModel.AdditionalInterestRate = tf.text;
            }
                break;
            case 3:
            {
                
            }
                break;
            case 5:
            {
                self.addOrderModel.TransactionReferenceNumber = tf.text;
                
            }
                break;
            case 6:
            {
                self.addOrderModel.PosCode = tf.text;
            }
                break;
            default:
                break;
        }
    }

}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return indexPath.row == self.titlesArray.count - 1 ? 150 : 80;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    WS(weakSelf)
    if ([self.addOrderModel.IsContinuedInvestment isEqual:@"1"]) {
        switch (indexPath.row) {
            case 0:
            {
                
            }
                break;
            case 1:
            {
                
            }
                break;
            case 3:
            {
                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                if (self.isOrderBianGeng) {
                    return;
                }
                
                [GFDatePicker showCustomDatePickerAtView:[UIApplication sharedApplication].keyWindow choosedDateBlock:^(NSDate *date) {
                    NSString *dateStr = [NSString stringWithFormat:@"%@",date];
                    NSString *timeStr = [dateStr componentsSeparatedByString:@" "][0];
                    weakSelf.addOrderModel.CalulationDate = timeStr;
                    NSLog(@"选中的日期的值%@",weakSelf.addOrderModel.CalulationDate);
                    LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[tableView cellForRowAtIndexPath:indexPath];
                    cell.contentTF.text = timeStr;
                    
                } cancelBlock:^{
                    
                }];
                
            }
                break;
            case 4:
            {
                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[tableView cellForRowAtIndexPath:indexPath];
                UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
                UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                    
                }];
                UIAlertAction *zhuanZhangaciton = [UIAlertAction actionWithTitle:@"转账" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    weakSelf.addOrderModel.PaymentCategory = @"0";
                    cell.contentTF.text = @"转账";
                }];
                UIAlertAction *posaciton = [UIAlertAction actionWithTitle:@"POS终端" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    weakSelf.addOrderModel.PaymentCategory = @"1";
                    cell.contentTF.text = @"POS终端";
                }];
                [alertVc addAction:cancelaciton];
                [alertVc addAction:zhuanZhangaciton];
                [alertVc addAction:posaciton];
                [self presentViewController:alertVc animated:YES completion:nil];
            }
                break;
            default:
                break;
        }
    }else{
        switch (indexPath.row) {
            case 0:
            {
                
            }
                break;
            case 1:
            {
                
            }
                break;
            case 3:
            {
                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                if (self.isUpdateOrder) {
                    if (self.isOrderBianGeng) {
                        return;
                    }
                }else{
                    
                }
                [GFDatePicker showCustomDatePickerAtView:[UIApplication sharedApplication].keyWindow choosedDateBlock:^(NSDate *date) {
                    NSString *dateStr = [NSString stringWithFormat:@"%@",date];
                    NSString *timeStr = [dateStr componentsSeparatedByString:@" "][0];
                    weakSelf.addOrderModel.CalulationDate = timeStr;
                    NSLog(@"选中的日期的值%@",weakSelf.addOrderModel.CalulationDate);
                    LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[tableView cellForRowAtIndexPath:indexPath];
                    cell.contentTF.text = timeStr;
                    
                } cancelBlock:^{
                    
                }];
                
            }
                break;
            case 4:
            {
                [[[UIApplication sharedApplication] keyWindow] endEditing:YES];
                LKAddProtocalMessageCell *cell = (LKAddProtocalMessageCell *)[tableView cellForRowAtIndexPath:indexPath];
                UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
                UIAlertAction *cancelaciton = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
                    
                }];
                UIAlertAction *zhuanZhangaciton = [UIAlertAction actionWithTitle:@"转账" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    weakSelf.addOrderModel.PaymentCategory = @"0";
                    cell.contentTF.text = @"转账";
                }];
                UIAlertAction *posaciton = [UIAlertAction actionWithTitle:@"POS终端" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                    weakSelf.addOrderModel.PaymentCategory = @"1";
                    cell.contentTF.text = @"POS终端";
                }];
                [alertVc addAction:cancelaciton];
                [alertVc addAction:zhuanZhangaciton];
                [alertVc addAction:posaciton];
                [self presentViewController:alertVc animated:YES completion:nil];
            }
                break;
            default:
                break;
        }
    }
 
}
-(NSArray *)titlesArray{
    if (!_titlesArray) {
        if ([self.addOrderModel.IsContinuedInvestment integerValue]) {
            _titlesArray = @[@"合同编号：",@"追加金额（元）",@"附加利率：%",@"起息日期：",@"支付方式：",@"交易参考号：",@"POS机终端号：",@"附加说明："];
        }else{
          _titlesArray = @[@"合同编号：",@"投资金额（元）：",@"附加利率：%",@"起息日期：",@"支付方式：",@"交易参考号：",@"POS机终端号：",@"附加说明："];
        }
        
    }
    return _titlesArray;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
